<?php

declare(ENCODING = 'UTF-8');

/*                                                                        *
 * This script is part of the TYPO3 project - inspiring people to share!  *
 *                                                                        *
 * TYPO3 is free software; you can redistribute it and/or modify it under *
 * the terms of the GNU General Public License version 2 as published by  *
 * the Free Software Foundation.                                          *
 *                                                                        *
 * This script is distributed in the hope that it will be useful, but     *
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *	
 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General      *
 * Public License for more details.                                       *
 *                                                                        */	

/**
 * @package auxo
 * @subpackage Logging
 * @version $Id$
 */

/**	
 * A Default Layout Formater
 * 
 * This default layout formater creates messages entries like:
 * <code>
 * 		31/12/2008 12:35 [Error]: my message
 * </code>
 *	
 * @package auxo
 * @subpackage Logging
 * @version $Id$	
 * @copyright Copyright belongs to the respective authors
 * @author AHN
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
 */
class  tx_auxo_LogDefaultLayout implements tx_auxo_LogLayoutInterface {

	/**
	 * Labels for all log levels
	 *
	 * @var unknown_type
	 */
	private $levelLabels = array( 
								tx_auxo_Logger::DEBUG => 'Debug',
								tx_auxo_Logger::FATAL => 'Fatal',
								tx_auxo_Logger::ERROR => 'Error',
								tx_auxo_Logger::WARNING => 'Warning',
								tx_auxo_Logger::TRACE => 'Trace',
								tx_auxo_Logger::INFO => 'Info'
						 	);
	
	/**
	 * Returns Content Type of this appender
	 *
	 * @return string $mimetype mimetype
	 */
	public function getContentType() {
		return ('text/text');
	}
						 	
	/**
	 * Formats an log event and returns a string
	 *
	 * @param tx_auxo_LogEvent $event A log event
	 * @return string $output Log event formated as string
	 */
	public function format(tx_auxo_LogEvent $event) {
		debug($event->getLevel());
		debug($event->getMessage());
		$output = sprintf ('%s [%s]: %s', 
		               date('d/m/Y H:i', $event->getTimestamp()),
		               $this->levelLabels[$event->getLevel()],
		               $event->getMessage()
				  );
		
		return $output;
	}
	
	/**
	 * Returns a log header 
	 *
	 * @return string $header returns a header for log entries
	 */
	public function getHeader() {		 
		return 'Date [Time]: Message';
	}
	
	/**
	 * Returns a log footer
	 *
	 * @return string $footer returns a footer for log entries
	 */
	public function getFooter() {
		return '';
	}
}
?>